package com.ssd.controller;

import com.ssd.service.FileUploadService;
import com.ssd.view.BaseResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/admin/system")
@Api(tags = "文件接口")
public class FileUploadController {

    @Autowired
    private FileUploadService fileUploadService;

    // <input type="file" name="file"/>
    @PostMapping("/fileUpload")
    @ApiOperation(value = "文件上传")
    public BaseResponse fileUpload(MultipartFile file) {
        //1 获取上传的文件
        //2 调用service的方法上传，返回minio路径
        String url = fileUploadService.upload(file);
        return new BaseResponse(url);
    }
}
